package com.sline.list;

import com.sline.bean.Student;

import java.util.ArrayList;
import java.util.List;

public class Demo1_List {
    public static void main(String[] args) {
//        demo1();

        // remove();

        // get();

        // set();
    }

    private static void set() {
        List list = new ArrayList();
        list.add(new Student("张三", 23));
        list.add(new Student("李四", 24));
        list.add(new Student("王五", 25));
        list.add(new Student("赵六", 26));

        list.set(1, new Student("孙七", 27));
        list.set(2, "哈哈");
        System.out.println(list);
    }

    private static void get() {
        List list = new ArrayList();
        list.add(new Student("张三", 23));
        list.add(new Student("李四", 24));
        list.add(new Student("王五", 25));
        list.add(new Student("赵六", 26));

        for (int i = 0; i < list.size(); i++) {
            Student s = (Student) list.get(i);
            System.out.println(s.getName() + "..." + s.getAge());
        }
    }

    private static void remove() {
        List list = new ArrayList();
        list.add(new Student("张三", 23));
        list.add(new Student("李四", 24));
        list.add(new Student("王五", 25));
        list.add(new Student("赵六", 26));

        list.remove(1);
        System.out.println(list);
    }

    private static void demo1() {
        List list = new ArrayList();
        list.add(new Student("张三", 23));
        list.add(new Student("李四", 24));
        list.add(new Student("王五", 25));
        list.add(new Student("赵六", 26));

        list.add(1, new Student("孙七", 27));
        System.out.println(list);
    }
}
